---
title: "Old Patronage during the New Deal"
subtitle: "Replication File: Tables and Figures (2/2)"
output: html_document
author: "Stephanie Ternullo, Simon Y. Shachter"
date: "2024-01-04"
---

<i>This replication file is the second of two replication files. It takes the organized data and displays the tables and figures in the publication.</i>

# Import Packages

```{r}

library( tidyverse )
library( readxl )
library( stargazer )
library( dotwhisker )
library( lfe )
library( Synth )
library( rio )
library( xtable )
library( MatchIt )
options( scipen = 10000 )

```

# Tables and Figures in Paper

## Figure 1: New Deal Spending Per Capita, Machine vs. Non-Machine Cities

```{r}

city_spending <- read_excel( "data_to_import/cities_public_private_machine.xls" ) %>%
  dplyr::select( stpc = STATEABL, sticpsr = STATE, ctyicpsr = COUNTY,
                 citycode = CITYCODE, cnty_name = COUNNAME, city = CTNAMEP,
                 machine, year = YEAR, CTCOUNT:PRIVATE, POPEST )  %>%
  left_join( state_abbrev, by = "stpc" ) %>%
  mutate_each( funs( toupper ), state_name ) %>%
  left_join( all_cities_1931, by = c( "state_name", "city" ) ) %>%
  filter( top_100_gibson == 1) %>%
  left_join( machine_cities, by = "fips" ) %>%
  mutate( machine_nd = ifelse( any_machine == 1, 1, 0 )) %>%
  replace_na( list( machine_nd = 0 ) ) %>%
  mutate( city = as.factor( city ),
          DIRREL = ifelse( year >= 1938 & is.na( DIRREL ), 0, DIRREL ),
          WORREL = ifelse( year >= 1938 & is.na( WORREL ), 0, WORREL ),
          worrel_pc = ( CWA + WPA + WORREL ) / POPEST,
          Machine = as.factor( ifelse( machine_nd == 1, "Machine", "Not Machine" ) ),
          Year = year ) 

fig1 <- city_spending %>%
  filter( top_100_gibson == 1 ) %>%
  filter( Year >= 1933 ) %>%
  group_by( Machine, Year ) %>%
  summarise( "Work Relief Per Capita" = mean( worrel_pc, na.rm = TRUE ) ) %>%
  ggplot( aes( Year, `Work Relief Per Capita` ) ) +
  geom_point( alpha = .75 ) +
  geom_line( aes( linetype = Machine ) ) +
  theme_bw() +
  geom_vline( xintercept = 1936, linetype = "dashed", color = "grey" )
ggsave( "figures/fig1.pdf" )

```


## Figure 2. Predictors of New Deal Spending Per Capita

```{r}

# Regression of indicators on work relief spending per capita
machine_money <- lm( works_per_cap ~ PCTUNEM + unemp_change +
                       dem_county_avg + dem_closeness + rep_index_state + avg_demrep  +
                       RTSAPC29 + RLDF3329 + TAXRTP29  +
                       black_pct + forgn_white_pct + pop_65 + femal_pct +
                       factor( region ), 
               data = filter( county_spending1939, 
                              top_100_gibson == 1 ) )
summary( machine_money )

# Dot and Whisker Plot of Regression
fig2 <- broom::tidy( machine_money ) %>%
  filter( !grepl( 'factor*', term ),
          term %in% c( "PCTUNEM", "unemp_change", "dem_closeness" ) ) %>%
  dwplot() %>%
  relabel_predictors( c( "PCTUNEM" = "Unemployment 1930",
                         "unemp_change" = "Change in Unemployment, 1930-1940",
                         "dem_closeness" = "Dem Closeness" ) ) +
  theme_bw() +
  xlab( "Coefficient Estimate" ) + ylab( "" ) +
  geom_vline( xintercept = 0,
              colour = "grey60",
              linetype = 2 ) +
  ggtitle( "" )  +
  theme( legend.position = "none" ) 
ggsave( "figures/fig2.pdf" )

```


## Figure 3: Machine vs. Non-Machine Presidential Voting, 1924-1940

```{r}

fig3a <- pres_vote24_40 %>%
  left_join( dplyr::select( all_cities_1931, fips, top_100_gibson ) ) %>%
  filter( top_100_gibson == 1 ) %>%
  left_join( machine_cities, by = "fips" ) %>%
  mutate( machine_nd_any = any_machine ) %>%
  replace_na( list( machine_nd_any = 0 ) ) %>%
  mutate( Machine = as.factor( ifelse( machine_nd_any == 1, "Machine", "Not Machine" ) ),
          Year = year) %>%
  group_by( Year, Machine ) %>%
  summarize( "Democratic Presidential Vote Share" = mean( dem_pctp, na.rm = TRUE ) ) %>%
  ggplot( aes( Year, `Democratic Presidential Vote Share` ) ) +
  geom_point() +
  geom_line( aes( linetype = Machine ) ) +
  theme_bw() +
  geom_vline( xintercept = 1932, linetype = "dashed", color = "grey" )
ggsave( "figures/fig3a.pdf" )

fig3b <- state_data_sen20_40 %>%
  left_join( dplyr::select( all_cities_1931, fips, top_100_gibson ) ) %>%
  filter( top_100_gibson == 1 ) %>%
  left_join( machine_cities, by = "fips" ) %>%
  mutate( machine_nd_any = any_machine ) %>%
  replace_na( list( machine_nd_any = 0 ) ) %>%
  mutate( Machine = as.factor( ifelse( machine_nd_any == 1, "Machine", "Not Machine" ) ),
          Year = year ) %>%
  group_by( Year, Machine ) %>%
  summarize( "Democratic Senatorial Vote Share" = mean( dem_pcts, na.rm = TRUE ) ) %>%
  ggplot( aes( Year, `Democratic Senatorial Vote Share` ) ) +
  geom_point() +
  geom_line( aes( linetype = Machine ) ) +
  theme_bw() +
  geom_vline( xintercept = 1932, linetype = "dashed", color = "grey" )
ggsave( "figures/fig3b.pdf" )

```


## Table 2. Work Relief Spending \& Democratic Vote Share in Machine vs. Non-Machine Counties, 1932-1940

```{r, results="asis"}

demvote_pres <- felm( dem_pctp ~ wpa_pc + wpa_pc:machine_nd_any
                      | year + fips | 0 | stpc,
                      data = filter( state_data_pres, top_100_gibson == 1 ) )

demvote_pres1 <- felm( dem_pctp ~ wpa_pc + wpa_pc:machine_nd_any +
                         black_pct + femal_pct + forgn_white_pct + density + pop_65 +
                         unemp_rate + num_demrep + other_spend_pc
                       | year + fips + region | 0 | stpc,
                      data = filter( state_data_pres, top_100_gibson == 1 ) )

demvote_sen <- felm( dem_pcts ~ works_grants_pc + works_grants_pc:machine_nd_any
                     | year + fips  | 0  | stpc,
                      data = filter( state_data_sen, top_100_gibson == 1 ) )

demvote_sen1 <- felm( dem_pcts ~ works_grants_pc + works_grants_pc:machine_nd_any +
                        black_pct + femal_pct + forgn_white_pct + density + pop_65 +
                        unemp_rate + num_demrep + other_spend_pc
                      | year + fips + region | 0  | stpc,
                      data = filter( state_data_sen, top_100_gibson == 1 ) )

stargazer( demvote_pres, demvote_pres1, demvote_sen, demvote_sen1, 
           star.cutoffs = c( 0.05, 0.01, 0.001 ), omit.stat = c( "LL", "ser", "f", "adj.rsq" ),
           ci = TRUE, ci.level = 0.95, single.row = FALSE,
           covariate.labels = c( "Work Grants  per Capita",
                                 "Work Grants  per Capita:Machine County",
                                 "Work Grants per Capita",
                                 "Work Grants per Capita:Machine County" ),
           add.lines = list( c( "Year & County FEs", "Yes", "Yes", "Yes", "Yes" ),
                             c( "Region FEs", "No", "Yes", "No", "Yes" ),
                             c( "Time-Varying Covariates", "No", "Yes", "No", "Yes" ) ),
           omit = c( "year", "fips", "stpc", "black_pct", "femal_pct", "forgn_white_pct", "density",
                     "pop_65", "unemp_rate", "region", "num_demrep", "other_spend_pc" ) )

```


### Effect Sizes
```{r}

state_data_sen %>%
  filter( year >= 1932, top_100_gibson == 1 ) %>%
  distinct(stpc, year, .keep_all = TRUE) %>%
  group_by( year ) %>%
  summarize( works_grants_pc = mean( works_grants_pc, na.rm = TRUE ),
             wpa_pc = mean( wpa_pc, na.rm = TRUE ) )

#1932-1936 Table 2
10.89689 * (0.399) # 4.35
#1936-1940
(10.89689 - 12.25317) * (0.399) # -0.54

```

## Figure 3. synthetic controls

### Pittsburgh

```{r}

synth_pitt_pres <- as.data.frame(
  synth_data %>%
    mutate( machine2 = ifelse( name == "PITTSBURGH_ALLEGHENY", 1,
                               ifelse( any_machine == 0, 0, NA ) ) ) %>%
    filter( !is.na( machine2 ),  year %in% c(1928, 1932, 1936, 1940 ) ) %>%
    group_by( name ) %>%
    mutate( count = n() ) %>%
    ungroup() %>%
    filter( count == 4 ) %>%
    group_by( fips ) %>%
    mutate( treat_id = cur_group_id() ) %>%
    ungroup() %>%
    arrange( -desc( year ), -desc( treat_id ) ) )

dataprep_pitt1 <- dataprep(
  foo = synth_pitt_pres,
  predictors = c( "tot_pop1930", "black_pct1930", "forgn_white_pct1930", "femal_pct1930",
                  "unemp_rate1930", "pop_651930", "density1930", "num_demrep",
                  "avg_works_grants_pc33_35" ),
  predictors.op = "mean",
  time.predictors.prior = c( 1928, 1932 ),
  special.predictors = list(
    list( "tot_pop1930", 1932, "mean" ),
    list( "black_pct1930", 1932, "mean" ),
    list( "forgn_white_pct1930", 1932, "mean" ),
    list( "femal_pct1930", 1932, "mean" ),
    list( "unemp_rate1930", 1932, "mean" ),
    list( "pop_651930", 1932, "mean" ),
    list( "density1930", 1932, "mean" ),
    list( "num_demrep", 1932, "mean" ),
    list( "avg_works_grants_pc33_35", 1932, "mean" ) ),
  dependent = "dem_pctp",
  unit.names.variable = "name",
  time.variable = "year",
  treatment.identifier = 46,
  controls.identifier = c( 1:45, 47:63 ), # CHANGE THIS
  time.optimize.ssr = c( 1928, 1932 ),
  time.plot = c( 1928, 1932, 1936, 1940 ),
  unit.variable = "treat_id" )

synth.out_pitt1 <- synth( data.prep.obj = dataprep_pitt1, method = "BFGS" )

pdf( "figures/fig4a.pdf" )
path.plot( synth.res = synth.out_pitt1, dataprep.res = dataprep_pitt1,
           Ylab = "FDR Vote Share", Xlab = "Year", Ylim = c( 20, 85 ),
           Legend = c( "Pittsburgh", "Synthetic Control" ),
           Legend.position = "bottomright" )
abline( v = 1936, lty = 2, col = "grey" )
dev.off()

```

### Chicago

```{r}

synth_chicago_pres <- as.data.frame(
  synth_data %>%
    mutate( machine2 = ifelse( name == "CHICAGO_COOK", 1,
                               ifelse( any_machine == 0, 0, NA ) ) ) %>%
    # Filter counties where pre-treatment covariates are missing
    filter( !is.na( machine2 ), year %in% c( 1928, 1932, 1936, 1940 ) ) %>%
    # Balanc the panel
    group_by( name ) %>%
    mutate( count = n() ) %>%
    ungroup() %>%
    filter( count == 4 ) %>%
    group_by( fips ) %>%
    mutate( treat_id = cur_group_id() ) %>%
    ungroup() %>%
    arrange( -desc( year ), -desc( treat_id ) ) ) 

dataprep_chi1 <- dataprep(
  foo = synth_chicago_pres,
  predictors = c( "tot_pop1930", "black_pct1930", "forgn_white_pct1930", "femal_pct1930",
                  "unemp_rate1930", "pop_651930", "density1930", "avg_works_grants_pc33_35",
                  "num_demrep" ),
  predictors.op = "mean",
  time.predictors.prior = c( 1928, 1932 ),
  special.predictors = list(
    list( "tot_pop1930", 1932, "mean" ),
    list( "black_pct1930", 1932, "mean" ),
    list( "forgn_white_pct1930", 1932, "mean" ),
    list( "femal_pct1930", 1932, "mean" ),
    list( "unemp_rate1930", 1932, "mean" ),
    list( "pop_651930", 1932, "mean" ),
    list( "density1930", 1932, "mean" ),
    list( "num_demrep", 1932, "mean" ),
    list( "avg_works_grants_pc33_35", 1932, "mean" ) ),
  dependent = "dem_pctp",
  unit.names.variable = "name",
  time.variable = "year",
  treatment.identifier = 12,
  controls.identifier = c( 1:11, 13:63 ), # CHANGE THIS
  time.optimize.ssr = c( 1928, 1932 ),
  time.plot = c( 1928, 1932, 1936, 1940 ),
  unit.variable = "treat_id" )

synth.out_chi1 <- synth( data.prep.obj = dataprep_chi1, method = "BFGS" )

pdf( "figures/fig4b.pdf" )
path.plot( synth.res = synth.out_chi1, dataprep.res = dataprep_chi1,
           Ylab = "FDR Vote Share", Xlab = "Year", Ylim = c( 20, 85 ),
           Legend = c( "Chicago", "Synthetic Control" ),
           Legend.position = "bottomright" )
abline( v = 1936, lty = 2, col = "grey" )
dev.off()

```


# Appendix


## Table A1. Descriptive Statistics

```{r}

# For Figure 2, Table A2/A3
tab_a1a <- county_spending1939 %>%
  filter( top_100_gibson == 1 ) %>%
  group_by(machine_nd) %>%
  summarize( "Works Grants per Capita" = mean( works_per_cap, na.rm = T ),
             "Unemployment Rate 1930" = mean( PCTUNEM, na.rm = T ),
             "Change in Unemployment, 1930-1940 " = mean( unemp_change, na.rm = T ),
             "Avg. Dem Vote Share, Prior 6 Yrs" = mean( dem_county_avg, na.rm = T ),
             "Electoral Competitiveness" = mean( dem_closeness, na.rm = T ),
             "Congressional Apportionment" = mean( rep_index_state, na.rm = T ),
             "# Dem Governor and Congress Reps" = mean( avg_demrep, na.rm = T ),
             "Retail Sales per Capita 1929" = mean( RTSAPC29, na.rm = T ),
             "Retail Sales Growth, 1929-1933" = mean( RLDF3329, na.rm = T ),
             "% Paying Income Tax 1929" = mean( TAXRTP29, na.rm = T ),
             #black_pct = mean( black_pct, na.rm = T ),
             #forgn_white_pct = mean( forgn_white_pct, na.rm = T ),
             #pop_65 = mean( pop_65, na.rm = T ),
             #femal_pct = mean( femal_pct, na.rm = T ) 
             ) 
 print( xtable( t( mapply( "format", tab_a1a, digits = 1 ) ) ) )

# For Table 2, A4

tab_a1b <- state_data_pres %>%
  filter( top_100_gibson == 1 ) %>%
  group_by( machine_nd_any ) %>%
  summarize( "Democratic Presidential Vote Share" = mean( dem_pctp, na.rm = T ),
             "Work Grants Per Capita" = mean( works_grants_pc, na.rm = T ),
             "Unemployment Rate" = mean( unemp_rate, na.rm = T ),
             "% Black" = mean( black_pct, na.rm = T ),
             "% Female" = mean( femal_pct, na.rm = T ),
             "% Foreign-Born" = mean( forgn_white_pct, na.rm = T ),
             "% Pop > 65" = mean( pop_65, na.rm = T ),
             "# Dem Governor and Congress Reps" = mean( num_demrep, na.rm = T ),
             "Other New Deal Spending Per Capita" = mean( other_spend_pc, na.rm = T )  ) 
 print( xtable( t( mapply("format", tab_a1b, digits = 1 ) ) ) )

tab_a1c <- state_data_sen %>%
  filter( top_100_gibson == 1 ) %>%
  group_by( machine_nd_any ) %>%
  summarize( "Democratic Senatorial Vote Share" = mean( dem_pcts, na.rm = T ))
 print( xtable( t( mapply( "format", tab_a1c, digits = 1 ) ) ) )
  

```


## Table A2. First Differences

```{r}

change <- city_spending %>%
  dplyr::select( city, stpc, year, worrel_pc,  machine_nd ) %>%
  gather( "variable", "value", -city, -stpc, -year, -machine_nd ) %>%
  unite( "var_yr", variable, year, sep = "" ) %>%
  group_by( city, stpc, var_yr ) %>%
  spread( var_yr, value ) %>%
  # Missing data for Albany in 1940
  mutate( wr_d1929_1940 = worrel_pc1940 - worrel_pc1929,
          wr_d1933_1936 = worrel_pc1936 - worrel_pc1933,
          wr_d1933_1940 = worrel_pc1940 - worrel_pc1933,
          wr_d1936_1940 = worrel_pc1940 - worrel_pc1936 )

city_wrd <- lm( wr_d1933_1936 ~ machine_nd, data = change )
city_wrd2 <- lm( wr_d1933_1940 ~ machine_nd, data = change )
city_wrd3 <- lm( wr_d1936_1940 ~ machine_nd, data = change )


stargazer( city_wrd, city_wrd2, city_wrd3, 
           star.cutoffs = c( 0.05, 0.01, 0.001 ), omit.stat = c( "LL", "ser", "f", "adj.rsq" ),
           ci = TRUE, ci.level = 0.95, single.row = FALSE,
           covariate.labels = c( "Machine City" ) )

```


## Table A3. Full Regression Results from Figure 2. Work Relief Distribution Model

```{r}

stargazer( machine_money,
           star.cutoffs = c( 0.05, 0.01, 0.001 ), omit.stat = c( "LL", "ser", "f", "adj.rsq" ),
           ci = TRUE, ci.level = 0.95, single.row = FALSE, digits = 3,
           covariate.labels = c( "Unemployment 1930", "Change in Unemployment, 1930-1940",
                                 "Avg Dem Vote", "Dem Closeness", "State Apportionment",
                                 "# Dem Governor and Congress Reps",
                                 "Retail Sales per Capita 1929", "Retail Sales Growth, 1929-1933",
                                 "% Paying Income Tax 1929",
                                 "% Black", "% Foreign-Born", "% Pop Over 65", "% Female" ),
           omit = c( "region" ), add.lines = list( c( "Region FEs", "Yes" ) ) )


```


## Table A4. Full Regression Results from Table 2, Spending and Democratic Vote Share
```{r}

stargazer( demvote_pres, demvote_pres1, demvote_sen, demvote_sen1, 
           star.cutoffs = c( 0.05, 0.01, 0.001 ), omit.stat = c( "LL", "ser", "f", "adj.rsq" ),
           ci = TRUE, ci.level = 0.95, single.row = FALSE,
           order = c( "wpa_pc", "wpa_pc:machine_nd_any",
                      "works_grants_pc", "works_grants_pc:machine_nd_any",
                      "other_spend_pc",
                      "black_pct", "femal_pct", "forgn_white_pct", "density", "pop_65",
                      "unemp_rate", "num_demrep" ),
           covariate.labels = c( "Work Grants (WPA) per Capita",
                                 "Work Grants (WPA) per Capita:Machine County",
                                 "Work Grants (all) per Capita",
                                 "Work Grants (all) per Capita:Machine County",
                                 "Other New Deal Spending per Capita",
                                 "% Black", "% Female", "% Foreign Born", "Pop Density", "Pop Over 65",
                                 "Unemployment Rate", "# Dem Governor and Congress Reps" ),
           add.lines = list( c( "Year & County FEs", "Yes", "Yes", "Yes", "Yes" ),
                             c( "Region FEs", "No", "Yes", "No", "Yes" ),
                             c( "Time-Varying Covariates", "No", "Yes", "No", "Yes" ) ) )

```


## Table A5. Full Regression Results from Table 2, With Time-Varying Machine Treatment
```{r}

a5_demvote_pres <- felm( dem_pctp ~ wpa_pc + wpa_pc:machine_nd
                         | year + fips | 0 | stpc,
                         data = filter( state_data_pres, top_100_gibson == 1 ) )

a5_demvote_pres1 <- felm( dem_pctp ~ wpa_pc + wpa_pc:machine_nd +
                          black_pct + femal_pct + forgn_white_pct + density + pop_65 +
                          unemp_rate + num_demrep + other_spend_pc
                          | year + fips + region | 0 | stpc,
                          data = filter( state_data_pres, top_100_gibson == 1 ) )

a5_demvote_sen <- felm( dem_pcts ~ works_grants_pc + works_grants_pc:machine_nd
                     | year + fips  | 0  | stpc,
                      data = filter( state_data_sen, top_100_gibson == 1 ) )
a5_demvote_sen1 <- felm( dem_pcts ~ works_grants_pc + works_grants_pc:machine_nd +
                         black_pct + femal_pct + forgn_white_pct + density + pop_65 +
                         unemp_rate + num_demrep + other_spend_pc
                         | year + fips + region | 0  | stpc,
                         data = filter( state_data_sen, top_100_gibson == 1 ) )

stargazer( a5_demvote_pres, a5_demvote_pres1, a5_demvote_sen, a5_demvote_sen1, 
           star.cutoffs = c( 0.05, 0.01, 0.001 ), omit.stat = c( "LL", "ser", "f", "adj.rsq" ),
           ci = TRUE, ci.level = 0.95, single.row = FALSE,
           order = c( "wpa_pc", "wpa_pc:machine_nd",
                      "works_grants_pc", "works_grants_pc:machine_nd",
                      "other_spend_pc",
                      "black_pct", "femal_pct", "forgn_white_pct", "density", "pop_65",
                      "unemp_rate", "num_demrep" ),
           covariate.labels = c( "Work Grants (WPA) per Capita",
                                 "Work Grants (WPA) per Capita:Machine County",
                                 "Work Grants (all) per Capita",
                                 "Work Grants (all) per Capita:Machine County",
                                 "Other New Deal Spending per Capita",
                                 "% Black", "% Female", "% Foreign Born", "Pop Density", "Pop Over 65",
                                 "Unemployment Rate", "# Dem Governor and Congress Reps" ),
           add.lines = list( c( "Year & County FEs", "Yes", "Yes", "Yes", "Yes" ),
                             c( "Region FEs", "No", "Yes", "No", "Yes" ),
                             c( "Time-Varying Covariates", "No", "Yes", "No", "Yes" ) ) )

```


## Table A6. Full Regression Results from Table 2, with State-Level Time Trends
```{r}


demvote_presa <- felm( dem_pctp ~ wpa_pc + wpa_pc:machine_nd_any + stpc*year
                      | year + fips | 0 | stpc,
                      data = filter( state_data_pres, top_100_gibson == 1 ) )

demvote_pres1a <- felm( dem_pctp ~ wpa_pc + wpa_pc:machine_nd_any +
                         black_pct + femal_pct + forgn_white_pct + density + pop_65 +
                         unemp_rate + num_demrep + other_spend_pc + stpc*year
                       | year + fips + region | 0 | stpc,
                      data = filter( state_data_pres, top_100_gibson == 1 ) )

demvote_sena <- felm( dem_pcts ~ works_grants_pc + works_grants_pc:machine_nd_any + stpc*year
                     | year + fips  | 0  | stpc,
                      data = filter( state_data_sen, top_100_gibson == 1 ) )

demvote_sen1a <- felm( dem_pcts ~ works_grants_pc + works_grants_pc:machine_nd_any +
                        black_pct + femal_pct + forgn_white_pct + density + pop_65 +
                        unemp_rate + num_demrep + other_spend_pc + stpc*year
                      | year + fips + region | 0  | stpc,
                      data = filter( state_data_sen, top_100_gibson == 1 ) )

stargazer( demvote_presa, demvote_pres1a, demvote_sena, demvote_sen1a,
           star.cutoffs = c( 0.05, 0.01, 0.001 ), omit.stat = c( "LL", "ser", "f", "adj.rsq" ),
           ci = TRUE, ci.level = 0.95, single.row = FALSE,
           order = c( "wpa_pc", "wpa_pc:machine_nd",
                      "works_grants_pc", "works_grants_pc:machine_nd",
                      "other_spend_pc",
                      "black_pct", "femal_pct", "forgn_white_pct", "density", "pop_65",
                      "unemp_rate", "num_demrep" ),
           covariate.labels = c( "Work Grants (WPA) per Capita",
                                 "Work Grants (WPA) per Capita:Machine County",
                                 "Work Grants (all) per Capita",
                                 "Work Grants (all) per Capita:Machine County",
                                 "Other New Deal Spending per Capita",
                                 "% Black", "% Female", "% Foreign Born", "Pop Density", "Pop Over 65",
                                 "Unemployment Rate", "# Dem Governor and Congress Reps" ),
           add.lines = list( c( "Year & County FEs", "Yes", "Yes", "Yes", "Yes" ),
                             c( "Region FEs", "No", "Yes", "No", "Yes" ),
                             c( "Time-Varying Covariates", "No", "Yes", "No", "Yes" ),
                             c( "State Time Trends", "Yes", "Yes", "Yes", "Yes" ) ),
           omit = c( "stpc", "year", "stpc:year" ) )

```


## Figure A1. Residuals
```{r}


cor( machine_money$residuals, filter( county_spending1939,
                                      top_100_gibson == 1 )$machine_nd )

resid_dat <- data.frame( cbind(
  machine_money$residuals,
  filter( county_spending1939, top_100_gibson == 1 )$machine_nd,
  filter( county_spending1939, top_100_gibson == 1 )$city ) )
names( resid_dat ) <- c( "residuals", "machine", "city" )
resid_dat <- resid_dat %>%
  mutate( residuals = as.numeric( residuals ),
          city = str_c( city, substr( residuals, 1, 3 ) ),
          machine = factor( ifelse( machine == 1, "Machine", "Not Machine" ) ) )

figA1 <- resid_dat %>%
  mutate( city = reorder( city, residuals ) ) %>%
  ggplot( mapping = aes( x = city, y = residuals, fill = machine ) ) +
  geom_bar( stat = "identity" ) +
  scale_fill_grey( name = "" ) +
  theme_void() +
  theme( legend.position="bottom" )
ggsave( "figures/figA1.pdf" )

```


